#include <iostream>
#include <string>
#include <unistd.h>
#include <pthread.h>

void *threadrun(void *args)
{
    //新线程
    std::string name = (const char*)args;
    while (true)
    {
        std::cout<<"我是新线程,name:"<<name<<std::endl;
        sleep(1);
    }
    return nullptr;
}

int main()
{
    pthread_t tid;
    pthread_create(&tid,nullptr,threadrun,(void*)"thread-1");
    while(true)
    {
        std::cout << "我是主线程" << std::endl;
        sleep(1);
    }
}